﻿using System;
using System.Collections.Generic;
using System.Text;
using AChance.Dal.Entity;
using AChance.Dal.Func;

namespace AChance.Bll.Func
{
    internal static class BllLogic
    {
        /// <summary>
        /// 主键相关
        /// </summary>
        public static class Key
        {
            static Key()
            {
                #region 初始化引用配置
                #region FDWORG
                RefConfigs.Add(nameof(FDWORG), new List<RefConfig>
                {
                    new RefConfig(nameof(FDWUDT.UDTUPDATEDATE)),
                    new RefConfig(nameof(FDWUDT.UDTUPDATETIME))
                });
                #endregion


                #endregion


            }
            /// <summary>
            /// 引用配置
            /// </summary>
            public static Dictionary<string, List<RefConfig>> RefConfigs { get; private set; } = new Dictionary<string, List<RefConfig>>();
            public class RefConfig
            {
                /// <summary>
                /// 表名
                /// </summary>
                public string TableName { get; set; }
                /// <summary>
                /// 主键字段
                /// </summary>
                public string KeyField { get; set; }
                /// <summary>
                /// 名称字段(该字段必须与主键对应，而且名称必定不会重复)
                /// </summary>
                public string NameField { get; set; }
                /// <summary>
                /// 同步存在
                /// </summary>
                public bool SyncExists { get; set; }
                public RefConfig(string keyField, string nameField = "", bool syncExists = false)
                {
                    TableName = DalEntity.GetName(keyField);
                    KeyField = keyField;
                    NameField = nameField;
                    SyncExists = syncExists;
                }
            }
        }
        /// <summary>
        /// 编码相关
        /// </summary>
        public static class Code
        {
            static Code()
            {
                #region 初始化引用配置
                #region 资质等级
                RefConfigs.Add(BllConst.CodeType.ZZDJ, new List<RefConfig>
                {
                    new RefConfig(nameof(FDWUDT.UDTUPDATEDATE)),
                    new RefConfig(nameof(FDWUDT.UDTUPDATETIME))
                });
                #endregion


                #endregion

            }
            /// <summary>
            /// 引用配置
            /// </summary>
            public static Dictionary<string, List<RefConfig>> RefConfigs { get; private set; } = new Dictionary<string, List<RefConfig>>();
            public class RefConfig
            {
                /// <summary>
                /// 表名
                /// </summary>
                public string TableName { get; set; }
                /// <summary>
                /// 字段名
                /// </summary>
                public string FieldName { get; set; }
                public RefConfig(string fieldName)
                {
                    TableName = DalEntity.GetName(fieldName);
                    FieldName = fieldName;
                }
            }
        }


    }
}
